/* let axios = require("axios");
let fs    = require("fs");
 */

/* //etao.html
axios({
      url : "https://www.etao.com/",
      headers :{}
})
.then( function( response ){
      fs.writeFile("../etao1.html", response.data , function( err ){
            if( err ){
                  console.error( err );
            }else{
                  console.log("一淘下载成功");
            }
     });
});

// index-min.scss
axios({
      url : "http://g.alicdn.com/thx/brix/2.1.0/??/brix-min.css,/gallery/dialog/index-min.css",
      
      headers :{}
})
.then( function( response ){
      fs.writeFile("../scss/index-min.scss", response.data , function( err ){
            if( err ){
                  console.error( err );
            }else{
                  console.log("下载成功");
            }
     });
});

//index2.scss
axios({
      url : "http://g.alicdn.com/kg/??countdown/2.0.1/index-min.css",
      
      headers :{}
})
.then( function( response ){
      fs.writeFile("../scss/index-min2.scss", response.data , function( err ){
            if( err ){
                  console.error( err );
            }else{
                  console.log("下载成功");
            }
     });
});
//index.scss
axios({
      url : "http://g.alicdn.com/etao/lego2-pc/0.2.4//app??/components/iform/index.css,/common/index.css,/pages/home/index.css?t=201801241624",
      headers :{}
})
.then( function( response ){
      fs.writeFile("../scss/index.scss", response.data , function( err ){
            if( err ){
                  console.error( err );
            }else{
                  console.log("下载成功");
            }
     });
});  */
//
/* axios({
      url : "https://www.etao.com/cjfl/info.htm?spm=1002.8274268.2699119.1.61062c34cRuiap&activityId=1617994",    
})
.then( function( response ){
      fs.writeFile("../etaolist.html", response.data , function( err ){
            if( err ){
                  console.error( err );
            }else{
                  console.log("下载成功");
               
            }
     });
});
 */
//轮播图部分
var index = 0;
        var button_next = $(".button-next");
        var button_prev = $(".button-prev");
        var slides = $(".slide");
        var container = $(".container");
        var wrapper = $(".wrapper");
        var t = null;

        function bindEvent() {
            button_next.on("click", addIndex);
            button_prev.on("click", reduceIndex);
            container.on("click", ".button-prev , .button-next", changeBanner);
            container.on("mouseover", function () {
                stop();
            })
            container.on("mouseout", function () {
                autoPlay();
            })
        }
        function changeBanner() {
            wrapper
                .stop(true)
                .animate({ left: -index * 800 });
        }
        function addIndex() {
            if (index === slides.length - 1) {
                wrapper.css({ left: 0 })
                index = 1;
            } else {
                index++;
            }
        }
        function reduceIndex() {
            if (index === 0) {
                index = slides.length - 1;
                wrapper.css({ left: - 800 * index })
                index--;
            } else {
                index--
            }
        }
        bindEvent();
        function autoPlay() {
            t = setInterval(function () {
                button_prev.trigger("click");
            }, 3000);
        }

        function stop() {
            clearInterval(t);
        }
        autoPlay();


       
